How To Create JavaScript onclick ON-OFF Switch Button Using HTML CSS and JavaScript
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>How To Create JavaScript onclick ON-OFF Switch Button Using HTML CSS and JavaScript</title>
</head>
<body>
<img id="clickimage" src="image/off.jpg" style="width:200px">
<!-- start on click btn -->
<button onclick="document.getElementById('clickimage').src='image/on.jpg'" class="on">ON</button>
<button onclick="document.getElementById('clickimage').src='image/off.jpg'" class="off">OFF</button>
</body>
</html>
body{margin: auto;display: flex;text-align: center;}
.on{padding: 5px 20px; background: #00a61d; color: #fff;border: 2px solid #ccc;font-size: 16px;border-radius: 0px;}
.off{padding: 5px 20px; background: #ff5d7d; color: #fff;border: 2px solid #ccc;font-size: 16px;border-radius: 0px;}
empty
Comments (0 )
Leave A Comment